
"""
slowly generate information
"""

import time

def slow(env, start_response):
    start_response("200 OK", [('Content-Type', 'text/plain')])
    return slow_generator()

def slow_generator():
    yield "slowly generating 20 timestamps\n"
    for i in range(20):
        yield "%s: %s\n" % (i, time.ctime())
        time.sleep(1)
    yield "done!"

__wsgi__ = slow

def test():
    from whiff.middleware import misc
    env = {}
    out = slow(env, misc.ignore)
    #txt = "".join(list(out))
    #print repr(txt)
    for x in out:
        print repr(x)

if __name__=="__main__":
    test()
